#include "tcpServer.hpp"
#include <iostream>

#include <memory>
#include <string>
using namespace std;
using namespace Server;

// ./tcpServer 8080

static void Usage(const string &proc)
{
    std::cout << "\nUsage: \n\t" << proc << " localport\n"
              << std::endl;
    exit(USAGE_ERR);
}

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERR);
    }
    uint16_t port = atoi(argv[1]);
    std::unique_ptr<TcpServer> tsvr(new TcpServer(port));
    tsvr->initServer();
    tsvr->run();
    return 0;
}